﻿/************************************************************************

   Extended Silverlight Toolkit

   Copyright (C) 2010-2012 Xceed Software Inc.

   This program is provided to you under the terms of the Microsoft Public
   License (Ms-PL) as published at http://extendedsilverlight.codeplex.com/license

   Please purchase a commercial version of this toolkit if you are using
   it in a commercial product. The commercial versions support the project,
   and also include more features for each control, priority support,
   source code, updates, removed watermark, and a proprietary license.

   Visit http://xceed.com and follow @datagrid on Twitter.

  **********************************************************************/

using System;
using System.Collections.Generic;
using Xceed.Silverlight.Data.Stats;

namespace Xceed.Silverlight.Data
{
  internal class OperationCompletedEventArgs<T> : EventArgs
  {
    internal OperationCompletedEventArgs( 
      DataSourceContext context,
      JumpMoveAndFetchResult<T> operation, 
      IList<Tuple<T, T>> replacements, 
      IList<T> deletions )
    {
      if( context == null )
        throw new ArgumentNullException( "context" );

      if( ( deletions != null ) && ( deletions.Count > 0 ) && ( !operation.EndPositionObject.IsOutOfBound ) )
        throw new ArgumentException( "The specified deletions list should be empty if the operation completed successfully.", "deletions" );

      this.Context = context;
      this.Action = OperationCompletedAction.Items;
      this.Operation = operation;
      this.Replacements = replacements;
      this.Deletions = deletions;
    }

    internal OperationCompletedEventArgs( StatParameters statParameters, StatResults dummyResults, StatResults realResults )
    {
      if( statParameters == null )
        throw new ArgumentNullException( "statParameters" );

      if( statParameters.Context == null )
        throw new ArgumentException( "The context is required.", "statParameters" );

      if( dummyResults == null )
        throw new ArgumentNullException( "dummyValue" );

      if( realResults == null )
        throw new ArgumentNullException( "realValue" );

      this.Context = statParameters.Context;
      this.Action = OperationCompletedAction.StatResult;
      this.StatParameters = statParameters;
      this.DummyStatResults = dummyResults;
      this.RealStatResults = realResults;

    }

    internal DataSourceContext Context
    {
      get;
      private set;
    }

    internal OperationCompletedAction Action
    {
      get;
      private set;
    }

    internal JumpMoveAndFetchResult<T> Operation
    {
      get;
      private set;
    }

    internal IList<Tuple<T,T>> Replacements
    {
      get;
      private set;
    }

    internal IList<T> Deletions
    {
      get;
      private set;
    }

    internal StatParameters StatParameters
    {
      get;
      private set;
    }

    internal StatResults DummyStatResults
    {
      get;
      private set;
    }

    internal StatResults RealStatResults
    {
      get;
      private set;
    }
  }
}
